﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_REWARD
    {
        private DateTime m_Date;
        private string m_DecideNumber;
        private string m_EmployeeCode;
        private string m_Form;
        private string m_Foundation;
        private string m_Person;
        private string m_Reason;
        private Guid m_RewardID;

        public HRM_PROCESS_REWARD()
        {
            this.m_RewardID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_Foundation = "";
            this.m_Reason = "";
            this.m_Form = "";
            this.m_Date = DateTime.Now;
            this.m_DecideNumber = "";
            this.m_Person = "";
        }

        public HRM_PROCESS_REWARD(Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            this.m_RewardID = RewardID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_Foundation = Foundation;
            this.m_Reason = Reason;
            this.m_Form = Form;
            this.m_Date = Date;
            this.m_DecideNumber = DecideNumber;
            this.m_Person = Person;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { this.m_RewardID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_REWARD_Delete", myParams, myValues);
        }

        public string Delete(Guid RewardID)
        {
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_REWARD_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid RewardID)
        {
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_REWARD_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid RewardID)
        {
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_REWARD_Delete", myParams, myValues);
        }

        public bool Exist(Guid RewardID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid RewardID)
        {
            string str = "";
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RewardID = reader.GetGuid(reader.GetOrdinal("RewardID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Foundation = Convert.ToString(reader["Foundation"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid RewardID)
        {
            string str = "";
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RewardID = reader.GetGuid(reader.GetOrdinal("RewardID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Foundation = Convert.ToString(reader["Foundation"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid RewardID)
        {
            string str = "";
            string[] myParams = new string[] { "@RewardID" };
            object[] myValues = new object[] { RewardID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_REWARD_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RewardID = reader.GetGuid(reader.GetOrdinal("RewardID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Foundation = Convert.ToString(reader["Foundation"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { level, code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_REWARD_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { level, code, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_REWARD_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_REWARD_GetList");
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_REWARD_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_REWARD_GetListByEmployee", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { this.m_RewardID, this.m_EmployeeCode, this.m_Foundation, this.m_Reason, this.m_Form, this.m_Date, this.m_DecideNumber, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_REWARD_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { this.m_RewardID, this.m_EmployeeCode, this.m_Foundation, this.m_Reason, this.m_Form, this.m_Date, this.m_DecideNumber, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_REWARD_Insert", myParams, myValues);
        }

        public string Insert(Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { RewardID, EmployeeCode, Foundation, Reason, Form, Date, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_REWARD_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { RewardID, EmployeeCode, Foundation, Reason, Form, Date, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_REWARD_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { RewardID, EmployeeCode, Foundation, Reason, Form, Date, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_REWARD_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_REWARD", "JobCode", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { this.m_RewardID, this.m_EmployeeCode, this.m_Foundation, this.m_Reason, this.m_Form, this.m_Date, this.m_DecideNumber, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_REWARD_Update", myParams, myValues);
        }

        public string Update(Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { RewardID, EmployeeCode, Foundation, Reason, Form, Date, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_REWARD_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { RewardID, EmployeeCode, Foundation, Reason, Form, Date, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_REWARD_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid RewardID, string EmployeeCode, string Foundation, string Reason, string Form, DateTime Date, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@RewardID", "@EmployeeCode", "@Foundation", "@Reason", "@Form", "@Date", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { RewardID, EmployeeCode, Foundation, Reason, Form, Date, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_REWARD_Update", myParams, myValues);
        }

        [DisplayName("Date"), Category("Column")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [DisplayName("DecideNumber"), Category("Column")]
        public string DecideNumber
        {
            get
            {
                return this.m_DecideNumber;
            }
            set
            {
                this.m_DecideNumber = value;
            }
        }

        [Category("Column"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [Category("Column"), DisplayName("Where")]
        public string Form
        {
            get
            {
                return this.m_Form;
            }
            set
            {
                this.m_Form = value;
            }
        }

        [Category("Column"), DisplayName("Foundation")]
        public string Foundation
        {
            get
            {
                return this.m_Foundation;
            }
            set
            {
                this.m_Foundation = value;
            }
        }

        [DisplayName("Person"), Category("Column")]
        public string Person
        {
            get
            {
                return this.m_Person;
            }
            set
            {
                this.m_Person = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_REWARD";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("Reason"), Category("Column")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }

        [DisplayName("RewardID"), Category("Primary Key")]
        public Guid RewardID
        {
            get
            {
                return this.m_RewardID;
            }
            set
            {
                this.m_RewardID = value;
            }
        }
    }
}

